<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<script>
	
function CreatePerson(name, salary)   //构造函数
	{
				var obj = new Object();
				obj.name= name;
				obj.salary = salary;
		
				obj.showName = function()
				{
					alert(this.name);
				};
	
				obj.showSalary = function()
				{
					alert(this.salary);
				};
				//出厂
		return obj;
	}
	
	var obj = CreatePerson('albert',35000);  // 没有 New 关键字
	
	//obj.showName();
	//obj.showSalary();
	
	var obj2 = CreatePerson('albert',55000);
	
	//obj2.showName();
	//obj2.showSalary();
	
	//工厂的缺点： 1.没有new 2.函数重复。
	alert(obj.showName);
	alert(obj2.showName);
	
	alert(obj.showName==obj2.showName);
	
</script>
</head>

<body>
</body>
</html>
